﻿<%@ Page Title="Quản lý đề thi" Language="C#" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true" CodeFile="frmAdTaoDeThi.aspx.cs" Inherits="Admin_frmAdTaoDeThi" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <div class="wrap">
        <h2>
            Quản lý đề thi |
            <asp:HyperLink ID="HyperLink1" runat="server" CssClass="node"
            NavigateUrl="~/Admin/frmQuyTacDe.aspx" BackColor="#F1F1F2" >Qui tắc đề thi</asp:HyperLink>
            |
            <asp:HyperLink ID="HyperLink2" runat="server" CssClass="node"
            NavigateUrl="~/Admin/frmTaoDeIn.aspx" BackColor="#F1F1F2" >Quản lý đề thi con</asp:HyperLink>
            |
            </h2>
    </div>
    
    <div style="clear: both;">&nbsp;</div>
    <%--<hr />--%>

    
    <div class="wrap" style="border: solid 1px #CCCCCC;">
    <table style="width: 100%">
        <tr>
            <td style="width: 10%">
                Tên đề thi</td>
            <td style="width: 10%">
            <asp:TextBox ID="txtTenDT" runat="server" Height="28px" TextMode="MultiLine" 
                Width="200px"></asp:TextBox>
            </td>
            <td rowspan="8" valign="top" style="width: 80%;">
                <asp:Panel ID="Panel1" runat="server" 
                    style="margin-right:20px;margin-left:5px;">
                    <asp:UpdatePanel ID="UpdatePanel5" runat="server">
                        <ContentTemplate>
                            Thông tin đề thi
                            <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                        AllowSorting="True" AutoGenerateColumns="False" CssClass="GridViewStyle" 
                        DataSourceID="SqlDataSource2" GridLines="None" 
                        onselectedindexchanged="GridView1_SelectedIndexChanged1" Width="670px" 
                                onrowcommand="GridView1_RowCommand" 
                                onrowdatabound="GridView1_RowDataBound">
                                <Columns>
                                    <asp:TemplateField HeaderText="" >
                                        <ItemTemplate>
                                            <input name="MyRadioButton" type="radio"  style="width:35px;"
                                                        value='<%# Eval("MaDT") %>' />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="MaDT" HeaderText="Mã Đề Thi" />
                                    <asp:BoundField DataField="TenDeThi" HeaderText="Tên Đề Thi" >
                                    <ItemStyle Width="150px" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="MaQT" HeaderText="Mã Quy Tắc" />
                                    <asp:BoundField DataField="TenMonHoc" HeaderText="Tên Môn Học" />
                                    <asp:BoundField DataField="msLopTC" HeaderText="Mã Lớp TC" />
                                    <asp:BoundField DataField="NgayApDung" DataFormatString="{0:d/M/yyyy}" 
                                        HeaderText="Ngày Áp Dụng" />
                                    <asp:HyperLinkField 
                                        Text="Xem Chi Tiết" DataNavigateUrlFields="MaDT" 
                                        DataNavigateUrlFormatString="~/Admin/frChitietDT.aspx?madt={0}"  />
                                    <asp:TemplateField ShowHeader="False">
                                    <ItemTemplate>
                                        <asp:ImageButton ID="ImageButton2" runat="server" CausesValidation="true" 
                                            CommandName="MyDelete" ImageUrl="../Images/cross.png" CommandArgument='<%#Eval("MaDT") %>'
                                            Text="Delete" style="padding-left:10px; padding-right:10px;"/>
                                        <ajaxToolkit:ModalPopupExtender BackgroundCssClass="modalBackground" ID="lnkDelete_ModalPopupExtender"
                                            runat="server" TargetControlID="ImageButton2" PopupControlID="DivDeleteConfirmation"
                                            OkControlID="ButtonDeleleOkay" CancelControlID="ButtonDeleteCancel">
                                        </ajaxToolkit:ModalPopupExtender>
                                        
                                        
                                        <ajaxToolkit:ConfirmButtonExtender ID="lnkDelete_ConfirmButtonExtender" runat="server" Enabled="True"
                                            TargetControlID="ImageButton2" DisplayModalPopupID="lnkDelete_ModalPopupExtender">
                                        </ajaxToolkit:ConfirmButtonExtender> 
                                    </ItemTemplate>

                                </asp:TemplateField>
    
                                </Columns>
                                <RowStyle CssClass="RowStyle" />
                                <EmptyDataRowStyle CssClass="EmptyRowStyle" />
                                <PagerStyle CssClass="PagerStyle" />
                                <SelectedRowStyle CssClass="SelectedRowStyle" />
                                <HeaderStyle CssClass="HeaderStyle" />
                                <EditRowStyle CssClass="EditRowStyle" />
                                <AlternatingRowStyle CssClass="AltRowStyle" />
                            </asp:GridView>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </asp:Panel>
            </td>
        </tr>
        <tr>
            <td style="width: 236px">
                Môn</td>
            <td style="width: 190px">
            <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                <ContentTemplate>
                    <asp:DropDownList ID="drlTenmon" runat="server" 
    Height="25px" Width="200px" DataSourceID="LinqDataSource6" DataTextField="TenMonHoc" 
                        DataValueField="MsMonHoc" AutoPostBack="True">
                    </asp:DropDownList>
                    <asp:LinqDataSource ID="LinqDataSource6" runat="server" 
                        ContextTypeName="DataClassesDataContext" Select="new (MsMonHoc, TenMonHoc)" 
                        TableName="tbl_MONHOCs">
                    </asp:LinqDataSource>
                </ContentTemplate>
            </asp:UpdatePanel>
            
            </td>
        </tr>
        <tr>
            <td style="width: 236px">
                Lớp tín chỉ</td>
            <td style="width: 190px">
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:DropDownList ID="drlmaloptc" runat="server" DataSourceID="LinqDataSource2" 
                DataTextField="MsLopTC" DataValueField="MsLopTC" Height="25px" 
    Width="200px" AutoPostBack="True">
                    </asp:DropDownList>
                    <asp:LinqDataSource ID="LinqDataSource2" runat="server" 
                        ContextTypeName="DataClassesDataContext" Select="new (MsLopTC)" 
                        TableName="tbl_LOPTCs" Where="MsMonHoc == @MsMonHoc">
                        <WhereParameters>
                            <asp:ControlParameter ControlID="drlTenmon" Name="MsMonHoc" 
                                PropertyName="SelectedValue" Type="String" />
                        </WhereParameters>
                    </asp:LinqDataSource>
                </ContentTemplate>
            </asp:UpdatePanel>
            
            </td>
        </tr>
        <tr>
            <td style="width: 236px">
                Quy tắc</td>
            <td style="width: 190px">
            <asp:UpdatePanel ID="UpdatePanel4" runat="server">
                <ContentTemplate>
                    <asp:DropDownList ID="drlQuytac" runat="server" 
    Height="25px" Width="200px" DataSourceID="LinqDataSource5" DataTextField="MaQT" 
                        DataValueField="MaQT" AutoPostBack="True">
                    </asp:DropDownList>
                    <asp:LinqDataSource ID="LinqDataSource5" runat="server" 
                        ContextTypeName="DataClassesDataContext" Select="new (MaQT)" 
                        TableName="tbl_QUYTACDETHIs">
                    </asp:LinqDataSource>
                </ContentTemplate>
            </asp:UpdatePanel>
            </td>
        </tr>
        <tr>
            <td style="width: 236px">
                &nbsp;</td>
            <td style="width: 190px">
            <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                <ContentTemplate>
                    <asp:DetailsView ID="DetailsView2" runat="server" Height="16px" 
                Width="200px" AutoGenerateRows="False" 
    DataSourceID="LinqDataSource7">
                        <EditRowStyle CssClass="yEditRowStyle" />
                        <RowStyle CssClass="yRowStyle" />
                        <Fields>
                            <asp:BoundField DataField="MaQT" 
                        HeaderText="Mã Quy Tắc" >
                            <ControlStyle Width="10px" />
                            <ItemStyle Width="25px" />
                            </asp:BoundField>
                            <asp:BoundField DataField="SoCH" 
                        HeaderText="Số Câu Hỏi" />
                            <asp:BoundField DataField="Kho" 
                        HeaderText="Số Câu Khó" />
                            <asp:BoundField DataField="TB" HeaderText="Số Câu TB" />
                            <asp:BoundField DataField="De" HeaderText="Số Câu Dễ" />
                            <asp:BoundField DataField="Thoigian" 
                        HeaderText="Thời gian" />
                        </Fields>
                        <HeaderStyle CssClass="yHeaderStyle" />
                        <PagerStyle CssClass="yPagerStyle" />
                        <AlternatingRowStyle CssClass="yAltRowStyle" />
                    </asp:DetailsView>
                    <asp:LinqDataSource ID="LinqDataSource7" runat="server" ContextTypeName="DataClassesDataContext" 
    Select="new (MaQT, SoCH, Kho, TB, De, Thoigian)" TableName="tbl_QUYTACDETHIs" 
    Where="MaQT == @MaQT">
                        <WhereParameters>
                            <asp:ControlParameter ControlID="drlQuytac" Name="MaQT" 
                                PropertyName="SelectedValue" Type="String" />
                        </WhereParameters>
                    </asp:LinqDataSource>
                </ContentTemplate>
            </asp:UpdatePanel>
            </td>
        </tr>
        <tr>
            <td style="width: 236px">
                Ngày thi</td>
            <td style="width: 190px">
                    
                    <asp:TextBox ID="txtDateTimePicker" runat="server" Width="196px"></asp:TextBox>
                </td>
        </tr>
        <tr>
            <td style="width: 236px">
                Chương&nbsp;học</td>
            <td style="width: 190px">
               <div style="border: solid 1px #CCCCCC;">
                    <asp:UpdatePanel ID="UpdatePanel6" runat="server">
                    <ContentTemplate>
                        <asp:DataList ID="DataList1" runat="server" DataSourceID="lqdsTenChuong">
                            <ItemTemplate>
                                <asp:CheckBox ID="cbxChuong" runat="server" 
                            Text='<%# Eval("TenChuong") %>' />
                                <asp:HiddenField ID="hdfValueMachuong" runat="server" 
                            Value='<%# Eval("MaChuong") %>' />
                            </ItemTemplate>
                        </asp:DataList>
                    </ContentTemplate>
                </asp:UpdatePanel>
                    <asp:LinqDataSource ID="lqdsTenChuong" runat="server" 
                    ContextTypeName="DataClassesDataContext" Select="new (MaChuong, TenChuong)" 
                    TableName="tbl_CHUONGHOCs" Where="MsMonHoc == @MsMonHoc">
                    <WhereParameters>
                        <asp:ControlParameter ControlID="drlTenmon" Name="MsMonHoc" 
                            PropertyName="SelectedValue" Type="String" />
                    </WhereParameters>
                </asp:LinqDataSource>
                </div>
            </td>
        </tr>
        <tr>
            <td style="width: 236px">
            <asp:UpdatePanel ID="UpdatePanel7" runat="server">
                        <ContentTemplate>
                            <asp:Button ID="btnThem" runat="server" onclick="btnThem_Click" CssClass="button"
                    Text="   Thêm" Width="96px" Height="27px" />
                        </ContentTemplate>
                    </asp:UpdatePanel>
                &nbsp;</td>
            <td style="width: 190px">
                    
                    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:TracNghiemTrucTuyenConnectionString %>" 
                        
                        SelectCommand="SELECT tbl_DETHI.MaDT, tbl_DETHI.MaQT, tbl_DETHI.TenDeThi, tbl_MONHOC.TenMonHoc, tbl_DETHI.MsLopTC, tbl_DETHI.NgayApDung FROM tbl_MONHOC INNER JOIN tbl_LOPTC ON tbl_MONHOC.MsMonHoc = tbl_LOPTC.MsMonHoc INNER JOIN tbl_DETHI ON tbl_LOPTC.MsLopTC = tbl_DETHI.MsLopTC WHERE tbl_DETHI.Deleted &lt;&gt;1">
                    </asp:SqlDataSource>
                    
                </td>
        </tr>
        </table>
    </div>
    
<%-- Bảng thông báo xóa dữ liệu--%>
    <asp:Panel runat="server" ID="DivDeleteConfirmation" Style="display: none;" class="modalBox">
    <div>
        <div class="popup_Titlebar" id="PopupHeader">
            <div class="TitlebarLeft">
                Xóa dữ liệu</div>
            <div class="TitlebarRight" onclick="$get('ButtonDeleteCancel').click();">
            </div>
        </div>
        <div class="popup_Body">
            <p>Bạn có chắc chắn muốn xóa ? </p>
        </div>
        <div class="popup_Buttons">
            <input id="ButtonDeleleOkay" value="Okay" type="button" />
            <input id="ButtonDeleteCancel" value="Cancel" type="button" />
        </div>
    </div>
    </asp:Panel>
    
    <script type="text/javascript" >
    
        $("#<%=txtDateTimePicker.ClientID%>").datepicker();
        function kiemtranhap() {
            if (($.trim($("#<%=txtDateTimePicker.ClientID%>").val()) == 0)
                || ($.trim($("#<%=txtTenDT.ClientID %>").val()) == 0)
                || ($.trim($("#<%=drlQuytac.ClientID %>").val()) == 0)) {
                alert("Thông báo! Tên đề thi, quy tắc hoặc ngày thi chưa có giá trị!");
                return false;

            }
             if (($.trim($("#<%=drlmaloptc.ClientID%>").val()) == 0)
                || ($.trim($("#<%=drlTenmon.ClientID %>").val()) == 0)) {
                alert("Thông báo! Chưa có môn học hoặc lớp tín chỉ!");
                return false;

            }
        }
    </script>
    </asp:Content>

